import { defineConfig } from 'vite'
import { resolve } from 'path'
import react from '@vitejs/plugin-react'
import dts from 'vite-plugin-dts';
import tsconfigPaths from "vite-tsconfig-paths";

export default defineConfig({
    plugins: [react(), dts({
        entryRoot: './lib/',
        strictOutput: true,
        insertTypesEntry: true,
    }), tsconfigPaths()],
    build: {
        lib: {
            entry: resolve(__dirname, 'lib/index.ts'),
            formats: ["es", "cjs"],
            fileName: (format) => `index.${format}.js`,
        },
        rollupOptions: {
            external: ['react', 'react/jsx-runtime'],
            output: {
                globals: {
                    react: 'React',
                    'react/jsx-runtime': 'jsxRuntime'
                },
            }
        },
        outDir: 'dist',
        minify: true,
    }
})